<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script src="/html/js/layui.js"></script>
    <script src="/html/js/util.js"></script>
    <link rel="stylesheet" href="/html/js/css/layui.css" media="all">
    <title>经理商品添加界面</title>
</head>

<script>
    async function add() {
        let info = await uploadAjaxPost("/product/upload", {
            productName: $("productName").value,
            productPrice: $("productPrice").value,
            productLocation: $("productLocation").value,
            productDate: $("productDate").value,
            pic: $("productImg").files[0]
        });
        if (info == "ok") {
            location.href = "/html/owner/ownerShow.html";
        }
    }
</script>


<body style="padding-top: 50px">
<div style="display: flex;justify-content: center">
    <div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品名称</label>
            <div class="layui-input-block">
                <input type="text" id="productName" required lay-verify="required" placeholder="商品名称"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">商品价格</label>
            <div class="layui-input-block">
                <input type="number" id="productPrice" required lay-verify="required" placeholder="商品价格"
                       class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">商品产地</label>
            <div class="layui-input-block">
                <input type="text" id="productLocation" required lay-verify="required" placeholder="商品产地"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">商品生产日期</label>
            <div class="layui-input-block">
                <input type="date" id="productDate" required lay-verify="required" placeholder="商品生产日期"
                       class="layui-input">
            </div>
        </div>
        <img src="" alt="" style="height: 150px" id="pImg">
        <input type="file" class="layui-btn" id="productImg" onchange="fileChange('productImg','pImg')">
        <button type="button" class="layui-btn" onclick="add()">
            <i class="layui-icon">&#xe67c;</i>添加商品
        </button>
    </div>
</div>
</body>
</html>